add build date from CI. (#1087)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Wed, 26 Apr 2023 17:21:59 +0000 (10:21 -0700)
committerGitHub <noreply@github.com>
Wed, 26 Apr 2023 17:21:59 +0000 (11:21 -0600)
gbversion.cmake
gbversion.h.in
gui/aboutdlg.cc
gui/aboutdlg.h
gui/aboutui.ui
gui/mainwindow.cc
main.cc

index 7ed8fc24c0f790aa4fa0663c464bf03329537b84..6a74336490bb6daaf41cd9b3cfa003b8d773a43f 100644 (file)
@@ -24,6 +24,14 @@ list(GET VERSION_COMPONENTS 2 GB.MICRO)
 set(GB.BUILD 32 CACHE STRING "Fourth component of Windows VERSIONINFO resource FILEVERSION and PRODUCTVERSION parameters.")
 set(GB.PACKAGE_RELEASE "" CACHE STRING "String to append to VERSION tuple.") # .e.g. "-beta20190413"
 set(GB.SHA $ENV{GITHUB_SHA})
+if(DEFINED ENV{GITHUB_SHA})
+  find_program(GIT_EXECUTABLE NAMES git)
+  if(NOT GIT_EXECUTABLE STREQUAL "GIT-NOTFOUND")
+    execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%aI
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    OUTPUT_VARIABLE GB.DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
+  endif()
+endif()
 string(TIMESTAMP GB.COPYRIGHT_YEAR "%Y" UTC)
 
 # may be overridden on cmake command line
index de72d684dafc93a73c86bbe637c7c65ebd8ea7ce..5334e826c188628331721d79d83c07e7cc30a552 100644 (file)
@@ -15,5 +15,6 @@
 #else
 #define VERSION "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@"
 constexpr char kVersionSHA[] = "@GB.SHA@";
+constexpr char kVersionDate[] = "@GB.DATE@";
 #define WEB_DOC_DIR "https://www.gpsbabel.org/htmldoc-@DOCVERSION@"
 #endif
index e98427924c2feea8729fcf28ef7da92d9032c3e8..4eb3539b47012d4c5a44a246d0ec01f169f8e693 100644 (file)
@@ -30,6 +30,7 @@
 
 AboutDlg::AboutDlg(QWidget* parent, const QString& ver1,
                    const QString& ver2, const QString& ver3,
+                   const QString& date,
                    const QString& installationId): QDialog(parent)
 {
   ui_.setupUi(this);
@@ -44,6 +45,11 @@ AboutDlg::AboutDlg(QWidget* parent, const QString& ver1,
   } else {
     tt.replace("$hash$", "Hash: " + ver3);
   }
+  if (date.isEmpty()) {
+    tt.replace("$date$", "");
+  } else {
+    tt.replace("$date$", "Date: " + date);
+  }
   tt.replace("$installationId$", installationId);
 
   // Not localized as it should never be seen.
index d20ca0af850922eb25d96f4c60723d246415d46c..578d089e118eedfb4e36822dfa164015756c45b3 100644 (file)
@@ -33,6 +33,7 @@ class AboutDlg: public QDialog
 public:
   AboutDlg(QWidget* parent,  const QString& ver1,
            const QString& ver2, const QString& ver3,
+           const QString& date,
            const QString& installationId);
 
 private:
index ae0d1b912b3ec8a09a1ef650e21069ca085d7072..b96ed8495c5f5d2f6b835584af1160b5ad8a49eb 100644 (file)
@@ -89,6 +89,7 @@ p, li { white-space: pre-wrap; }
 &lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;(Using backend $babelversion$)&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;$hash$&lt;/p&gt;
+&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;$date$&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;$upgradetestmode$&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Installation ID: $installationId$&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
index 78b632b980792203cd6fbc9862c7736b54359a9c..21352c239a5996b1c528af437a1429f3ee1c3970 100644 (file)
@@ -1148,7 +1148,12 @@ void MainWindow::moreOptionButtonClicked()
 //------------------------------------------------------------------------
 void MainWindow::aboutActionX()
 {
-  AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), kVersionSHA, babelData_.installationUuid_);
+  QDateTime date = QDateTime::fromString(kVersionDate, Qt::ISODate);
+  QString utcdate;
+  if (date.isValid()) {
+    utcdate = date.toUTC().toString(Qt::ISODate);
+  }
+  AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), kVersionSHA, utcdate, babelData_.installationUuid_);
   aboutDlg.setWindowTitle(tr("About %1").arg(appName));
   aboutDlg.exec();
 }
diff --git a/main.cc b/main.cc
index 3f5a08a91c5b096b7ecc472e9f7de2677a002c81..9e90077ab1adaeb4591ba8d2b0ed76355af39f89 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -492,6 +492,12 @@ run(const char* prog_name)
         if(sizeof(kVersionSHA) > 1) {
           warning(MYNAME ": Repository SHA: %s\n", kVersionSHA);
         }
+        if(sizeof(kVersionDate) > 1) {
+          QDateTime date = QDateTime::fromString(kVersionDate, Qt::ISODate);
+          if (date.isValid()) {
+            warning(MYNAME ": Date: %s\n", qPrintable(date.toUTC().toString(Qt::ISODate)));
+          }
+        }
         warning(MYNAME ": Compiled with Qt %s for architecture %s\n",
                 QT_VERSION_STR,
                 qPrintable(QSysInfo::buildAbi()));